<template>
  <div class="bar">
    <div class="navbar" :class="{'slide': isShow}">
      <div class="nav" @click="slide"></div>
      <div class="center">{{msg}}</div>
      <a class="fly" href="javascript:;">登录</a>
    </div>
    <div>
      <div class="cover" v-show="isShow" @click="slide"></div>
      <div class="sideBar" :class="{'slide': isShow}">
        <div class="user-info">
          <ul class="user-on">
            <li class="login">
              <a href="javasript:;">登录</a>
            </li>
          </ul>
        </div>
        <div class="list-ul">
          <a href="javascript:;">
            <i class="icon icon-quanbu"></i>全部
          </a>
          <a href="javascript:;">
            <i class="icon icon-quanbu"></i>精华
          </a>
          <a href="javascript:;">
            <i class="icon icon-quanbu"></i>分享
          </a>
          <a href="javascript:;">
            <i class="icon icon-quanbu"></i>问答
          </a>
          <a href="javascript:;">
            <i class="icon icon-quanbu"></i>招聘
          </a>
          <a href="javascript:;" class="item-line">
            <i class="icon icon-quanbu"></i>消息
          </a>
          <a href="javascript:;">
            <i class="icon icon-quanbu"></i>关于
          </a>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "Navbar",
  data() {
    return {
      isShow: false
    };
  },
  props: {
    msg: String
  },
  methods: {
    slide() {
      this.isShow = !this.isShow;
      // console.log(this.isShow);
    }
  }
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="less">
.bar {
  width: 100%;
  height: 44px;
}
.navbar {
  width: 100%;
  height: 44px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  transition: all 0.3s ease;
  .nav {
    width: 49px;
    height: 100%;
    background: url()
      no-repeat 50%;
    background-size: 19px 16px;
  }
  .center {
    flex: 1;
    text-align: center;
  }
  .fly {
    font-size: 14px;
    margin-right: 10px;
    color: #42b983;
  }
}
.slide{
  transform: translateX(200px);
}
.cover {
  width: 100%;
  height: 100%;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 7;
}
.sideBar {
  width: 200px;
  height: 100%;
  background: #fff;
  position: fixed;
  top: 0;
  left: -200px;
  z-index: 10;
  transition: all 0.3s ease;
}
.user-info {
  padding: 23px;
  font-size: 15px;
  .user-on {
    margin: 8xp 9px;
  }
  .login {
    position: relative;
    height: 24px;
    line-height: 24px;
    padding-left: 34px;
    &:after {
      content: "";
      width: 24px;
      height: 24px;
      background: url()
        no-repeat 0;
      background-size: 100%;
      position: absolute;
      top: 0;
      left: 0;
    }
  }
  a {
    color: #313131;
  }
}
.list-ul {
  margin: 0 24px;
  padding-top: 9%;
  border-top: 1px solid #d4d4d4;
  display: flex;
  flex-direction: column;
  a {
    padding: 9% 0;
    font-size: 14px;
    color: #313131;
    font-weight: 700;
  }
  .item-line {
    border-top: 1px solid #d4d4d4;
  }
}
.icon {
  position: relative;
  margin-right: 30px;
  &:after {
    content: "\E604";
    position: absolute;
    left: 0;
    top: 0;
    color: #2c3e50;
  }
}
</style>
